package com.ruoyi.labour.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.labour.domain.LabourBusinessLicense;
import com.ruoyi.labour.domain.LabourUploadCard;
import com.ruoyi.labour.domain.vo.PageVo;
import com.ruoyi.labour.enums.BusinessLicenseStatus;
import com.ruoyi.labour.enums.UploadCardStatus;
import com.ruoyi.labour.mapper.UploadCardMapper;
import com.ruoyi.labour.service.UploadCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UploadCardServiceImpl implements UploadCardService {

    @Autowired
    private UploadCardMapper uploadCardMapper;

    /**
     * 修改身份证状态
     *
     * @param status
     * @param id
     * @return
     */
    @Override
    public R updateUploadCard(Integer status, Integer id) {
        int i = uploadCardMapper.checkUploadIsExist(id);
        if (i > 0) {
            if ("[0][1][2]".contains("[" + status + "]")) {
                uploadCardMapper.updateUpdate(status, id);
                return R.ok("修改成功,当前身份证状态为" + UploadCardStatus.parse(status));
            } else {
                return R.fail("身份证状态值不存在");
            }
        } else {
            return R.fail("该身份证信息不存在");
        }
    }

    /**
     * 查询身份证
     *
     * @param pageVo
     * @return
     */
    @Override
    public R selectCard(PageVo pageVo) {

        PageHelper.startPage(pageVo.getPage(), pageVo.getSize());
        List<LabourUploadCard> list = uploadCardMapper.selectRecruit();
        PageInfo pageInfo = new PageInfo(list);

        return R.ok(pageInfo);
    }

    /**
     * 根据id查询身份证
     *
     * @param id
     * @return
     */
    @Override
    public R selectBusiness(Integer id) {
        int i = uploadCardMapper.checkUploadIsExist(id);
        if (i > 0) {
            LabourUploadCard card = uploadCardMapper.selectId(id);

            return R.ok(card);
        } else {
            return R.fail("身份证信息不存在");
        }
    }


}
